<template>
  <el-form
    ref="registerForm"
    size="large"
    :model="registerForm"
    @submit.prevent="register"
  >
    <el-form-item>
      <el-radio-group v-model="registerType">
        <el-radio-button value="employ">我是求职者</el-radio-button>
        <el-radio-button value="boss">我是招聘方</el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <el-input :prefix-icon="User" placeholder="请输入手机号"></el-input>
    </el-form-item>
    <el-form-item>
      <el-input
        :prefix-icon="Lock"
        type="password"
        placeholder="请设置密码"
      ></el-input>
    </el-form-item>
    <el-form-item>
      <div class="verification-code-group">
        <el-input :prefix-icon="Lock" placeholder="请输入验证码"></el-input>
        <el-button
          type="primary"
          class="verification-code-btn"
          @click="sendVerificationCode"
        >
          获取验证码
        </el-button>
      </div>
    </el-form-item>
    <el-form-item>
      <div class="agreement">
        <label>
          <input type="checkbox" v-model="agreedToTerms" />
          <span>同意《注册协议》和《隐私政策》</span>
        </label>
      </div>
      <el-button
        class="button"
        type="primary"
        auto-insert-space
        @click="register"
      >
        注册
      </el-button>
    </el-form-item>
    <el-form-item class="flex">
      <el-link type="info" :underline="false" @click="$emit('toggle-login')">
        ← 返回登录
      </el-link>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { ref } from 'vue'
import { User, Lock } from '@element-plus/icons-vue'

const registerType = ref('employ') // 默认为求职者
// const registerForm = ref('employ')

const agreedToTerms = ref(false)

const sendVerificationCode = () => {
  console.log('发送验证码')
}

const register = () => {
  console.log('执行注册操作')
  console.log('注册类型:', registerType) // 检查这里的值是否正确
}
</script>

<style scoped>
/* RegisterForm 样式 */
.verification-code-group {
  display: flex;
  align-items: center;
}
.verification-code-btn {
  margin-left: 15px;
}
.agreement {
  display: flex;
  align-items: center;
}
.agreement a {
  margin-left: 1rem;
  color: #3b82f6;
}
.button {
  width: 100%;
}
.flex {
  display: flex;
  justify-content: space-between;
  width: 100%;
}
</style>
